<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="签到时间" prop="signAt">
        <el-date-picker clearable
                        v-model="queryParams.signAt"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择签到时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="inList" @selection-change="handleSelectionChange">
      <el-table-column label="签到用户" align="center" prop="userId" >
      <template slot-scope="scope">
        {{scope.row.easyUser.nickName}}
      </template>
      </el-table-column>
      <el-table-column label="课程名称" align="center" prop="courseCardId">
        <template slot-scope="scope">
          {{scope.row.easyCourseCard.name}}
        </template>
      </el-table-column>
      <el-table-column label="教练姓名" align="center" prop="coachId" >
        <template slot-scope="scope">
          {{scope.row.easyCoach.name}}
        </template>
      </el-table-column>
      <el-table-column label="照片" align="center" prop="image" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.image" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="签到日期【唯一索引用】" align="center" prop="date" />
      <el-table-column label="签到时间" align="center" prop="signAt" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.signAt, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listIn} from "@/api/debao/signIn";

export default {
  name: "In",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 课程签到表格数据
      inList: [],
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        date: null,
        signAt: null,
        courseCardId: null,
        coachId: null,
        image: null,
        isDel: null
      },
      // 表单参数
      form: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询课程签到列表 */
    getList() {
      this.loading = true;
      listIn(this.queryParams).then(response => {
        this.inList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
